package net.xiduth.events.button;

import net.xiduth.events.ButtonEvent;
import net.xiduth.events.EventManager;
import net.xiduth.game.player.Player;
import net.xiduth.game.player.actions.spells.BoltEnchantingAction;
import net.xiduth.game.player.actions.spells.BoltEnchantingAction.MagicEnchant;

/**
 * @author Tyluur <ItsTyluur@Gmail.com>
 * @since 2012-07-29
 */
public class BoltEnchantingEvent implements ButtonEvent {

	@Override
	public boolean init() {
		return EventManager.register(432, this);
	}

	@Override
	public boolean handle(Player player, int interfaceId, int buttonId,
			int packetId, int slotId, int slotId2) {
		MagicEnchant enchant = MagicEnchant.getByButton(buttonId);
		if (enchant != null) {
			player.getActionManager().setAction(new BoltEnchantingAction(enchant, packetId == 14 ? 1 : packetId == 67 ? 5 : 5));
		}
		return false;
	}

}
